﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>三分厂开卡未检验理化试验申请</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style>
        .easyui-linkbutton{margin-left:20px;}
        table tr td{padding:0px 5px}
    </style>
</head>
<body>
    <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <form id="searchForm" method="post">
	    	<table>
	    		<tr  class="divLabel">
	    			<td>订单号:</td>
                    <td>件号:</td>
                    <td>批次号:</td>
	    		</tr>
	    		<tr >
	    			<td><input class="easyui-textbox" type="text" name="mfgOrderName" style="width: 120px; height: 22px"/></td>
	    			<td><input class="easyui-textbox" type="text" name="ProductName" style="width: 120px; height: 22px"/></td>
                    <td><input class="easyui-textbox" type="text" name="ContainerName" style="width: 120px; height: 22px" id="ContainerName"/></td>
                    <td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchData()">查询</a></td>
	    			<td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchReset()">重置</a></td>
	    		</tr>
	    	</table>
	    </form>
        </div> 
    </div>

    <div class="panelSection">    
        <div class="easyui-panel " title="结果区域" style="padding:3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <div class="easyui-layout" style="height:458px;width:90%;">
                <div data-options="region:'west'" style="width:57%;">
                    <table id="MainTable" style="width: 100%; height: 420px" data-options="rownumbers:true,pagination:false,striped:true,checkOnSelect:true,selectOnCheck:true,singleSelect:false,pageNumber:1,pageSize:5,pageList:[5,10,20]"></table>
                    <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                             layout:['first','prev','next','last','manual','info'],              
                                total: 0,
                                showPageList: false,
                                showPageInfo: false,
                                showRefresh: false,
                                afterPageText:'共&nbsp{pages}&nbsp页',
                                buttons:[{
                                        iconCls:'',
                                        text:'Go',
                                        id:'pageGo'
                                }]  
                            ">
                      </div>
                </div>
                <div data-options="region:'center'"><table id="DetailTable" style="width: 100%; height: 455px" data-options="rownumbers:true,border:false"></table></div>
            </div>
            <div style="height:50px;line-height:20px;padding:10px 0">
                <span>工艺路线及版本：</span><span id="workflowid" style="min-width:100px;display:inline-block;"></span><span style="margin-left:20px;">工序信息：</span><input class="easyui-combobox" id="workflowstep" style="width:200px"/>
            </div>
        </div>
      </div>
      <div class="panelSection">    
        <div class="easyui-panel " title="按钮区域" style="padding:3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
             <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.ShowLHDialog()">理化试验申请</a>
        </div>
      </div>

     <!--信息提示区域-->
    <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/dayjs.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    /*
    创建人：longb
    日期：2023-06-12
    描述：三分厂开卡未检验理化试验申请JS
    */
    var page = {
        pagetotal: 0,
        pageSize: 20,
        pageNumber: 1,
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/ZsHandler/ZSEntrustMeteringHandler.ashx",
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
        bind: function () {
            $("#MainTable").datagrid({
                checkOnSelect: false,
                selectOnCheck: false,
                singleSelect: true,
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pagetotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                onSelect: function (index, row) {
                    page.getChildContainerNo(row);
                },
                columns: [[
                 { field: 'MFGORDERNAME', title: '生产订单', width: 100 },
                 { field: 'PRODUCTNAME', title: '零件号', width: 100 },
                 { field: 'PRODUCTDESCRIPTION', title: '零件名称', width: 100 },
		         { field: 'QTY', title: '计划', width: 100,align: 'center' },
		         { field: 'CONNUMBER', title: '在制', width: 100, align: 'center' },
                 { field: 'PLANNEDSTARTDATE', title: '计划开始', width: 110, formatter: function (value, row, index) { if (value != null) { return dayjs(value).format("YYYY-MM-DD"); } } },
                 { field: 'PLANNEDCOMPLETIONDATE', title: '计划完成', width: 110, formatter: function (value, row, index) { if (value != null) { return dayjs(value).format("YYYY-MM-DD"); } } },
               ]]
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.getContainerNoCheckData();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.getContainerNoCheckData();
            });

            //理化检测项信息
            $("#DetailTable").datagrid({
                checkOnSelect: false,
                selectOnCheck: false,
                singleSelect: true,
                fitColumns:true,
                columns: [[
                 { field: 'CONTAINERNAME', title: '批次号', width: 150,  },
                 { field: 'QTY', title: '在制数', width: 70,align: 'center' },
		         { field: 'CONTAINERTYPE', title: '批次类型', width: 100,formatter: function (value, row, index) {if(value=="2"){return "批量加工";}else if(value=="3"){return "批量带子序号";}else if(value=="7"){return "单件加工";} } }
                ]]
            });

        },
        //查询
        searchData: function () {
            page.reset(false, true);
            page.pageNumber = 1;
            page.getContainerNoCheckData();
        },
        //查询重置
        searchReset: function () {
            $('#searchForm').form('clear');
        },
        getContainerNoCheckData: function () {
            $('#DetailTable').datagrid('loadData', []);
            var frdata = $('#searchForm').serializeArray();
            var data = {};
            $.each(frdata, function () {
                data[this.name] = this.value
            });
            var param = {
                action: "GetContainerNoCheckData",
                pageSize: page.pageSize,
                pageNumber: page.pageNumber,
                data: JSON.stringify(data)
            };
            page.post(param, function (res) {
                if (res.Result) {
                    page.pagetotal = res.RowCount;
                    $('#MainTable').datagrid('loadData', res.DBTable)
                }
            });

        },
        getChildContainerNo: function (row) {
            $('#workflowid').html(row.WORKFLOWNAME+":"+row.WORKFLOWREVISION);
            page.post({ action: 'GetChildContainerNo', data: JSON.stringify(row),ContainerName:$('#ContainerName').textbox('getValue') }, function (res) {
                $('#DetailTable').datagrid('loadData', res.DBTable);
                $('#workflowstep').combobox({
                    data:res.ReturnData,
                    valueField: 'WORKFLOWSTEPID',
		            textField: 'WORKFLOWSTEPNAME',
                    panelHeight:res.ReturnData.length>=20?'300px':'auto',
                });
            });
        },
        ShowLHDialog: function () {
            var obj={href:page.rootPath+'/forms/Custom/EntrustMeteringPopupNewForm.aspx',width:930,height:760};
            var conRow= $('#DetailTable').datagrid('getSelected');
            var proRow=$('#MainTable').datagrid('getSelected');
            var WorkflowStepID=$('#workflowstep').combobox('getValue');
            var WorkflowStepName=$('#workflowstep').combobox('getText');
            if(conRow==null){displayMessage('请选择一条批次信息再进行操作',false);return;}
            if(WorkflowStepID==""){displayMessage('请选择一条工序信息再进行操作',false);return;}
            var param={
                ContainerName:conRow.CONTAINERNAME,
                ContainerID:conRow.CONTAINERID,
                WipQty:conRow.QTY,
                ProductName:proRow.PRODUCTNAME,
                ProductDescription:proRow.PRODUCTDESCRIPTION,
                ProductID:proRow.PRODUCTID,
                WorkflowStepID:WorkflowStepID,
                WorkflowStepName:WorkflowStepName,
            };
             page.post({ action: 'GetLHData', data: JSON.stringify(param) }, function (res) {
                if(res.Result){
                     page.showModalDialog(obj);
                }
             });
        },
        showModalDialog: function (obj) {
          var someValue = window.showModalDialog(obj.href, "", "dialogWidth:" + obj.width + "px; dialogHeight:" + obj.height + "px; status=no; center: Yes; resizable: NO;");
        },
        //清除方法，重要！！！
        reset: function (iscondition, isresult) {
            clearMessage();
        },
        //post数据
        post: function (param, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        }
    };
    $(function () {
        page.init();
    });
</script>
